package poo.varie;

import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;

public class JListTest {
  public static void main(String[] args) {
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame frame = new JFrame("JList Test");
    frame.setLayout(new FlowLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    String[] selections = { "green", "red", "orange", "dark blue" };
    JList list = new JList(selections);
    list.setSelectedIndex(1);
    System.out.println(list.getSelectedValue());
    frame.add(new JScrollPane(list));
    frame.pack();

    frame.setVisible(true);
  }
}

/*String[] selections = { "virginia", "salvatore", "federico", "vincenzo" };
list_attaccanti = new JList();
list_attaccanti.setBounds(10, 54, 277, 247);
list_attaccanti.setSelectedIndex(1);
scrollPane.setViewportView(list_attaccanti);
list_attaccanti.setModel(listModel);
for (int i = 0; i < selections.length; i++) {
	listModel.addElement(selections[i]);
}*/